<template>
  <div class="con">
    <div class="zhong">
      <el-carousel height="18vw">
        <el-carousel-item v-for="item in lunbo"
                          :key="item.id">
          <img :src="item.imgUrl"
                style="width: 100%;height: 100%;"
                @click="linkLunbo(item)" />
        </el-carousel-item>
      </el-carousel>
    </div>
    <div class="div">
      <el-breadcrumb separator-class="el-icon-arrow-right">
        <!-- :to="{ path: '/' }" -->
        <el-breadcrumb-item :to="{ path: '/home' }">首页</el-breadcrumb-item>
        <el-breadcrumb-item class="dangqian">公告信息</el-breadcrumb-item>
      </el-breadcrumb>
      <div class="nei">
        <div class="one">
          <div class="list">
            <div v-for="(item, i) in types"
                 :key="i"
                 @click="statt(i)"
                 class="item"
                 :class="{ sta1: sta == i }">
              {{ item.name }}
            </div>
          </div>
          <div class="list1">
            <div v-for="i in list"
                 :key="i.id"
                 class="item"
                 @click="to(i.id)">
              <div class="ul1">{{i.name}}</div>
              <div class="ul2">
                摘要：{{i.title}}
              </div>
              <div class="ul3">
                发布时间：{{i.caAt?i.caAt.substring(0,10):''}}
              </div>
            </div>
            <el-pagination background
                           layout="prev, pager, next"
                           :total="total"
                           :page-size="pageSize"
                           :current-page.sync="pageNum"
                           @current-change="handleCurrentChange"
                           prev-text="上一页"
                           next-text="下一页"
                           class="aut">
              <!-- :hide-on-single-page="true" -->
            </el-pagination>
          </div>
        </div>
        <div class="two">
          <div class="re">热点信息</div>
          <div class="ul">
            <div v-for="(a, i) in remen"
                 :key="i"
                 class="li"
                 @click="to(a.id)">{{a.title}}</div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: "",
  data() {
    return {
      list: [],
      sta: 0,
      lunbo: [],
      types: [],
      pageNum: 1,
      pageSize: 15,
      total: 0,
      remen:[]
    };
  },
  //注册组件
  components: {},
  //生命周期 - 创建完成（访问当前this实例）
  created() {
    this.isinput();
    this.getlunbo();
    this.gettypes();
    this.getremen()
  },
  //生命周期 - 挂载完成（访问DOM元素）
  mounted() { },
  //计算属性
  computed: {},
  //方法
  methods: {
    getlunbo(){
      this.$postRequest('/api/cms/slide/list',{
        type: '5'
      }).then(res=>{
        this.lunbo=res.data
      })
    },
    gettypes(){
      this.$postRequest('/api/mallNews/getNewsClass',{}).then(res=>{
        res.data.unshift({id:'',name:'全部'})
        this.types=res.data
        this.getlist()
      })
    },
    getlist(){
      this.$postRequest('/api/mallNews/getNewsList',{
        classId: this.types[this.sta].id,
        pageNum: this.pageNum,
        pageSize: this.pageSize
      }).then(res=>{
        this.list=res.data.list
        this.total=res.data.total
      })
    },
    getremen(){
      this.$postRequest('/api/mallNews/getHotNews',{}).then(res=>{
        this.remen=res.data
      })
    },
    linkLunbo(item) {
      if (item.mode == 0) {
        this.$router.push({ name: 'detail', query: { id: item.goodsId } })
      } else if (item.mode == 1) {
        window.location.href = item.linkUrl
      }
    },
    isinput() {
      this.$store.commit("setDValue", false);
    },
    statt(i) {
      if(this.sta!=i){
        this.sta = i;
        this.pageNum=1
        this.total=0
        this.getlist()
      }
    },
    handleCurrentChange(currentPage) {
      this.getdetail()
    },
    to(id) {
      this.$router.push({ path: "/home/notticitem", query: { id: id } });
    }
  }
};
</script>
<style scoped lang="scss">
.con {
  background-color: #f9f9f9;
  .img {
    width: 100%;
  }
  .div {
    width: 1400px;
    margin: auto;
    /deep/ .el-breadcrumb {
      height: 48px;
      font-size: 14px;
      line-height: 48px;
      .el-breadcrumb__inner {
        color: #999;
        font-weight: 500;
      }
      .dangqian .el-breadcrumb__inner {
        color: #1a69e0;
      }
    }
    .nei {
      width: 100%;
      display: flex;
      align-items: flex-start;
      margin-bottom: 30px;
      .one {
        width: 1100px;
        margin-right: 20px;
        .list {
          width: 1100px;
          height: 50px;
          background: #ffffff;
          margin-bottom: 20px;
          display: flex;
          align-items: center;
          padding: 0 10px;
          .item {
            width: 100px;
            height: 50px;
            line-height: 50px;
            cursor: pointer;
            text-align: center;
            &.sta1 {
              color: #1a69e0;
              position: relative;
              &::after {
                content: '';
                width: 100px;
                height: 2px;
                background: #1a69e0;
                position: absolute;
                bottom: 0;
                left: 0;
              }
            }
          }
        }
        .list1 {
          width: 100%;
          background: #ffffff;
          border: 1px solid #eeeeee;
          .item {
            width: 100%;
            border-bottom: 1px solid #eeeeee;
            padding: 20px 20px 24px;
            cursor: pointer;
            &:hover {
              box-shadow: 0px 2px 14px 1px rgba(133, 133, 133, 0.15);
              .ul1 {
                color: #1a69e0;
              }
            }
            .ul1 {
              font-size: 16px;
              font-family: PingFang SC;
              font-weight: 500;
              color: #000000;
              margin-bottom: 18px;
            }
            .ul2 {
              font-size: 14px;
              font-family: PingFang SC;
              font-weight: 500;
              color: #666666;
              line-height: 20px;
              margin-bottom: 18px;
            }
            .ul3 {
              height: 14px;
              font-size: 14px;
              font-family: PingFang SC;
              font-weight: 500;
              color: #999999;
              line-height: 20px;
            }
          }
          .aut {
            text-align: center;
            margin-top: 14px;
            margin-bottom: 14px;
          }
          /deep/ .el-pagination button,
          .el-pagination span:not([class*='suffix']) {
            width: 60px;
          }
        }
      }
      .two {
        width: 280px;
        background: #ffffff;
        border: 1px solid #eeeeee;
        // padding:0 16px 20px 16px;
        .re {
          width: 280px;
          height: 50px;
          background: #ffffff;
          border-bottom: 1px solid #eeeeee;
          line-height: 50px;
          font-size: 16px;
          font-family: Microsoft YaHei;
          font-weight: 400;
          color: #000000;
          padding-left: 20px;
        }
        .ul {
          width: 100%;
          padding: 0 16px 20px 16px;
          .li {
            width: 100%;
            height: 42px;
            line-height: 42px;
            border-bottom: 1px solid #eeeeee;
            font-size: 14px;
            font-family: Microsoft YaHei;
            font-weight: 400;
            color: #666666;
            overflow: hidden;
            white-space: nowrap;
            text-overflow: ellipsis;
            -o-text-overflow: ellipsis;
            cursor: pointer;
            &:hover {
              color: #000000;
            }
          }
        }
      }
    }
  }
}
</style>